/**
 * 公共api
 */
import axios from 'axios'
import { post, get, baseURL } from '@/utils/request'
import { useUserStore } from '@/stores/user/index.js'
/**
 * 用户登陆-用户名密码
 */
export const SignIn = (params) => post('/h5/account/login', params)
/**
 * 注册
 */
export const register = (params) => post('/h5/register', params)
/**
 * 用户登陆-注册登录验证码校验手机号
 */
export const getPhoneCode = (phone) => get('/h5/validate/'+phone)

/**
 * 用户登陆-sms登录
 */
export const smsLogin = (params) => post('/h5/sms/login', params)
// 获取用户信息
export const getUserInfo = () => get('/h5/member/info')

// 发送验证码
export const sendCode = (data) => post('/h5/sendCode', data)
// 退出
export const toLogout = () => get('/h5/member/logout')
// 新增个人信息
export const addInformation = (data) => post('/h5/certificate/add', data)
// 编辑个人信息
export const updateInformation = (data) => post('/h5/certificate/update', data)
/**
 * 上传图片
 */
export const uploadImg = (data) => {
  let userStore = useUserStore()
  return axios({
    url: baseURL + '/h5/oss/upload',
    method: 'post',
    headers: {
      'content-type': 'multipart/form-data;charset=UTF-8',
      'Authorization': userStore.token,
    },
    data
  })
}
